document.querySelector("html").style.fontSize = (window.innerWidth / 16) + "px";
window.onorientationchange = () => {
  window.location.reload();
};

$(function () {
  var val

  var length = $(".tbutton").length
  console.log(length)
  for (let i = 0; i < length; i++) {
    val = $(".tbutton").eq(i).attr("value")
    console.log(val)
    if (val == 1) {
      $(".tbutton").eq(i).css("background", "linear-gradient(rgba(1,254,200, 1), rgba(0,211,198, 1))")
    }
    else if (val == 2) {
      $(".tbutton").eq(i).css("background", "linear-gradient(rgba(8,249,154, 1), rgba(0,212,169, 1))")
    }
    else if (val == 3) {
      $(".tbutton").eq(i).css("background", "linear-gradient(rgba(99,255,4, 1), rgba(2,236,0, 1))")
    }
    else if (val == 4) {
      $(".tbutton").eq(i).css("background", "linear-gradient(rgba(62,220,92, 1), rgba(14,187,78, 1))")
    }
    else if (val == 5) {
      $(".tbutton").eq(i).css("background", "linear-gradient(rgba(0,217,46, 1), rgba(0,149,0, 1))")
    }
  }

  $(".tbutton").click(function (e) {
    console.log($(this).attr("value"))
    window.location.href = 'index.html?data=' + encodeURIComponent(JSON.stringify({
      difficulty: $(this).attr("value")
    }));
  })
})
